package org.lookahead.parent.common.utils;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.http.HttpStatus;

import java.io.Serializable;

/**
 * @author qujianning
 */
public class HttpResult implements Serializable {

    private static final long serialVersionUID = -9019461351553461708L;

    /**
     * response code
     */
    private int code;
    /**
     * body信息文本
     */
    private String body;
    /**
     * response code 200 标志
     */
    private boolean ok;

    public HttpResult() {
    }

    public HttpResult(int code, String body) {
        this.code = code;
        this.body = body;
        this.ok = code == HttpStatus.SC_OK;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public boolean isOk() {
        return ok;
    }

    public void setOk(boolean ok) {
        this.ok = ok;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("code", code)
                .append("body", body)
                .append("ok", ok)
                .toString();
    }
}
